//
//  HomePageCollectionViewCell.m
//  miaopai
//
//  Created by Crow Zhang on 15/11/17.
//  Copyright © 2015年 Crow Zhang. All rights reserved.
//

#import "HomePageCollectionViewCell.h"

@interface HomePageCollectionViewCell()

@property(nonatomic, retain)UIImageView *pic;

@property(nonatomic, retain)UIView *backView;

@property(nonatomic, retain)UILabel *label;

@end

@implementation HomePageCollectionViewCell

- (void)dealloc
{
    [_pic release];
    [_backView release];
    [_label release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}

- (void)creatView
{
    self.pic = [[UIImageView alloc] init];
    _pic.backgroundColor = [UIColor whiteColor];
    _pic.layer.shadowOffset = CGSizeMake(0, 3);
    _pic.layer.shadowColor = [[UIColor grayColor] CGColor];
    _pic.layer.shadowOpacity = 0.8;
    [self.contentView addSubview:_pic];
    [_pic release];
    
    self.backView = [[UIView alloc] init];
    self.backView.backgroundColor = [UIColor blackColor];
    self.backView.alpha = 0.2;
    [self.contentView addSubview:self.backView];
    [_backView release];
    
    self.label = [[UILabel alloc] init];
    self.label.textAlignment = NSTextAlignmentCenter;
    self.label.textColor = [UIColor whiteColor];
    self.label.shadowOffset = CGSizeMake(1, 1);
    self.label.font = [UIFont systemFontOfSize:25];
    self.label.shadowColor = [UIColor blackColor];
    [self.contentView addSubview:self.label];
    [_label release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.pic.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.backView.frame = self.pic.frame;
    self.label.frame = CGRectMake(0, self.frame.size.height / 2.0 - 15, self.frame.size.width, 30);
}

- (void)setText:(NSString *)text
{
    if (_text != text) {
        [_text release];
        _text = [text copy];
    }
    self.label.text = text;
}

- (void)setImageName:(NSString *)imageName
{
    if (_imageName != imageName) {
        [_imageName release];
        _imageName = [imageName copy];
    }
    NSLog(@"%@", _imageName);
    self.pic.image = [UIImage imageNamed:imageName];
}

@end
